package com.memorypalace.study.biz;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.memorypalace.pojo.StudyList;
import com.memorypalace.pojo.StudyScheme;
import com.memorypalace.study.mapper.CardStudyRecordMapper;
import com.memorypalace.study.mapper.StudyListMapper;
import com.memorypalace.study.mapper.StudySchemeMapper;
@Service("studyListBiz")
public class StudyListBizImpl implements IStudyListBiz {

	@Autowired
	private StudyListMapper studyListMapper;
	@Autowired
	private StudySchemeMapper studySchemeMapper;
	@Autowired
	private CardStudyRecordMapper cardStudyRecordMapper;


	@Override
	public void updateStudyList(StudyList usl) {
		studyListMapper.updateStudyList(usl);
		
	}
  
	@Override
	public Boolean deleteStudyList(String studyListId) {
		
		cardStudyRecordMapper.setStudyListIdNull(studyListId);
	        return studyListMapper.deleteStudyList(studyListId);
	}



	@Override
	public Boolean insertStudyList(StudyList asl) {
		
		
		return studyListMapper.insertStudyList(asl);
		
	}



	@Override
	public List<StudyList> selectStudyList(String userId) {
	
		return studyListMapper.selectStudyList(userId);
	}

	@Override
	public StudyList selectStudyListByStudyListId(String studyListId) {
		// TODO Auto-generated method stub
		StudyList studyList = studyListMapper.selectStudyListByStudyListId(studyListId);
		StudyScheme studyScheme = studySchemeMapper.getStudySchemeWithAllSchemeById(studyList.getStudySchemeId());
		studyList.setStudyScheme(studyScheme);
		return studyList;
	}

	


}
